$(function () {

    var barChart = echarts.init(document.getElementById("echarts-bar-chart"));
    var baroption = {
        tooltip : {
            trigger: 'axis'
        },
        legend: {
            data:['累计确诊','累计死亡']
        },
        grid:{
            x:30,
            x2:40,
            y2:24
        },
        calculable : true,
        xAxis : [
            {
                type: 'category',
                data: ['2.24', '2.25', '2.26', '2.27', '2.28', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9']
            }
        ],
        yAxis : [
            {
                type : 'value'
            }
        ],
        series : [
            {
                name:'累计确诊',
                type:'bar',
                data:[1432,1437,1447,1467,1479,1484,1495,1504,1513,1526,1532,1554,1565,1583],
                /*                markPoint : {
                                    data : [
                                        {type : 'max', name: '最大值'},
                                        {type : 'min', name: '最小值'}
                                    ]
                                },*/
                markLine : {
                    data : [
                        {type : 'average', name: '平均值'}
                    ]
                }
            },
            {
                name:'累计死亡',
                type:'bar',
                data:[9,9,9,9,9,9,9,9,9,9,9,9,9,9],
                /*                markPoint : {
                                    data : [
                                        {name : '年最高', value : 182.2, xAxis: 7, yAxis: 183, symbolSize:18},
                                        {name : '年最低', value : 2.3, xAxis: 11, yAxis: 3}
                                    ]
                                },*/
                markLine : {
                    data : [
                        {type : 'average', name : '平均值'}
                    ]
                }
            }
        ]
    };
    barChart.setOption(baroption);

    window.onresize = barChart.resize;

    var lineChart = echarts.init(document.getElementById("echarts-line-chart"));
    var lineoption = {
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: ['本土新增趋势', '境外输入趋势', '新增确诊趋势']
        },
        grid: {
            x: 40,
            x2: 40,
            y2: 24
        },
        calculable: true,
        xAxis: [
            {
                type: 'category',
                boundaryGap: false,
                data: ['2.24','2.25','2.26','2.27','2.28','3.1','3.2','3.3', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9']
            }
        ],
        yAxis: [
            {
                type: 'value'
            }
        ],
        series: [
            {
                name: '新增确诊趋势',
                type: 'line',
                data: [10,5,10,20,12,5,11,9,9,13,6,22,11,18],
                markPoint: {
                    data: [
                        { type: 'max', name: '最大值' },
                        { type: 'min', name: '最小值' }
                    ]
                },
                markLine: {
                    data: [
                        { type: 'average', name: '平均值' }
                    ]
                }
            },
            {
                name: '本土新增趋势',
                type: 'line',
                data: [2,1,2,0,0,0,0,0,0,0,0,1,6,4],
                /*                markPoint: {
                                    data: [
                                        { name: '周最低', value: -2 }
                                    ]
                                },*/
                markLine: {
                    data: [
                        { type: 'average', name: '平均值' }
                    ]
                }
            },
            {
                name: '境外输入趋势',
                type: 'line',
                data: [8,4,8,20,12,5,11,9,9,13,6,21,5,14],
                /*                markPoint: {
                                    data: [
                                        { name: '周最低', value: 4}
                                    ]
                                },*/
                markLine: {
                    data: [
                        { type: 'average', name: '平均值' }
                    ]
                }
            }
        ]
    };

    lineChart.setOption(lineoption);
    $(window).resize(lineChart.resize);





    var pieChart = echarts.init(document.getElementById("echarts-pie-chart"));
    var pieoption = {
        title : {
        },
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            type: 'scroll',
            orient: 'vertical',
            x: 'right',
            data: ['东城区','西城区','通州区','大兴区','密云县','怀柔区','丰台区','石景山区','门头沟区','昌平区','朝阳区','海淀区','顺义区','房山区','延庆县']
        },
        calculable : true,
        series: [
            {
                name:'现有确诊',
                type:'pie',
                radius: '70%',
                center: ['30%', '50%'],
                data:[
                    {name:'东城区',value:0},
                    {name:'西城区',value:7},
                    {name:'通州区',value:3},
                    {name:'大兴区',value:9},
                    {name: '密云县',value: 0},
                    {name: '怀柔区',value: 0},
                    {name: '丰台区',value: 23 },
                    {name: '石景山区',value: 0 },
                    {name: '门头沟区',value: 0},
                    {name: '昌平区', value: 1 },
                    {name: '朝阳区', value: 31},
                    {name: '海淀区',value: 12},
                    {name: '顺义区', value: 1 },
                    {name: '房山区',value: 6 },
                    {name: '平谷区',value:null },
                    {name: '延庆县',value: 0}
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }

            }
        ]
    };
    pieChart.setOption(pieoption);
    $(window).resize(pieChart.resize);


    var mapChart = echarts.init(document.getElementById("echarts-map-chart"));
    var mapoption = {
        color: ['gold','aqua','lime'],
        title : {
            text: '北京疫情情况',
            x:'center'
        },
        tooltip : {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            x:'left',
            data:['现有确诊','累计治愈','累计确诊']
        },
        dataRange: {
            min: 0,
            max: 500,
            x: 'left',
            y: 'bottom',
            text:['高','低'],           // 文本，默认为数值文本
            calculable : true
        },
        toolbox: {
            show: true,
            orient : 'vertical',
            x: 'right',
            y: 'center',
            feature : {
               // mark : {show: true},
                dataView : {show: true, readOnly: false},
                restore : {show: true},
                saveAsImage : {show: true}
            }
        },
        roamController: {
            show: true,
            x: 'right',
            mapTypeControl: {
                '北京': true
            }
        },
        series : [
            {
                name: '现有确诊',
                type: 'map',
                mapType: '北京',
                zoom:1.0 ,
                roam: true,
                itemStyle:{
                    normal:{label:{show:true}},
                    emphasis:{label:{show:false}}
                },
                data:[
                    {name:'东城区',value:0},
                    {name:'西城区',value:7},
                    {name:'通州区',value:3},
                    {name:'大兴区',value:9},
                    {name: '密云县',value: 0},
                    {name: '怀柔区',value: 0},
                    {name: '丰台区',value: 23 },
                    {name: '石景山区',value: 0 },
                    {name: '门头沟区',value: 0},
                    {name: '昌平区', value: 1 },
                    {name: '朝阳区', value: 31},
                    {name: '海淀区',value: 12},
                    {name: '顺义区', value: 1 },
                    {name: '房山区',value: 6 },
                    {name: '平谷区',value:null },
                    {name: '延庆县',value: 0}
                ]
            },
            {
                name: '累计治愈',
                type: 'map',
                mapType: '北京',
                itemStyle:{
                    normal:{label:{show:true}},
                    emphasis:{label:{show:false}}
                },
                data:[
                    {name:'东城区',value:6},
                    {name:'西城区',value:6},
                    {name:'通州区',value:3},
                    {name:'大兴区',value:111},
                    {name: '密云县',value: 0},
                    {name: '怀柔区',value: 4},
                    {name: '丰台区',value: 286},
                    {name: '石景山区',value: 12},
                    {name: '门头沟区',value: 4},
                    {name: '昌平区', value: 50 },
                    {name: '朝阳区', value: 9},
                    {name: '海淀区',value: 26 },
                    {name: '顺义区', value: 45 },
                    {name: '房山区',value: 12},
                    {name: '平谷区',value:null },
                    {name: '延庆县',value: 0}
                ]
            },
            {
                   name: '累计确诊',
                   type: 'map',
                   mapType: '北京',
                   itemStyle:{
                       normal:{label:{show:true}},
                       emphasis:{label:{show:true}}
                   },
                   data:[
                       {name:'东城区',value:19},
                       {name:'西城区',value:66},
                       {name:'通州区',value:24},
                       {name:'大兴区',value:143},
                       {name: '密云县',value: 7},
                       {name: '怀柔区',value: 8},
                       {name: '丰台区',value: 349},
                       {name: '石景山区',value: 15},
                       {name: '门头沟区',value: 5},
                       {name: '昌平区', value: 70 },
                       {name: '朝阳区', value: 106},
                       {name: '海淀区',value: 102 },
                       {name: '顺义区', value: 46 },
                       {name: '房山区',value: 31},
                       {name: '平谷区',value:null },
                       {name: '延庆县',value: 1}
                   ]
               }
        ]
    };
    mapChart.setOption(mapoption);
    $(window).resize(mapChart.resize);
});
